package zkrt.cc.fishelevatorservice.filter;


import lombok.extern.slf4j.Slf4j;
import zkrt.cc.fishelevatorservice.filter.vo.UserRightViewModel;


@Slf4j
public class UserContextHolder {

    private UserContextHolder() {}

    private static ThreadLocal<UserRightViewModel> USERINFO_HOLDER = new ThreadLocal<>();

    public static void setUserInfo(UserRightViewModel userInfo) {
        if(USERINFO_HOLDER.get() == null) {
            USERINFO_HOLDER.set(userInfo);
        }
    }

    public static UserRightViewModel getUserInfo() {
        return USERINFO_HOLDER.get();
    }

    public static void removeUserInfo() {
        USERINFO_HOLDER.remove();
    }
}
